<template>
	<view class="box" :style="{'padding-top':systemHeight+28.5+'px'}">
		<view class="head">
			<image class="back" src="/static/img/back.png" @click="back"></image>
			<view class="title">{{title}}</view>
			<view class="right"></view>
		</view>
		<view class="small_title">Card number</view>
		<view class="card">
			<image class="card_img" src="/static/img/payX.png"></image>
			<input class="input_card" placeholder="Card number" v-model="cardnum" />
			<image class="scan" src="/static/img/camera.png"></image>
		</view>
		<view class="yy_cvv">
			<view class="yy_cvv_box">
				<view class="small_title">Period of validity</view>
				<input class="input" placeholder="MM /YY" v-model="mm" />
			</view>
			<view class="yy_cvv_box">
				<view class="small_title">CVV</view>
				<input class="input" placeholder="CVV" v-model="cvv" type="safe-password" />
			</view>
		</view>
		<view class="safe">
			<image class="safe_img" src="/static/img/safe.png"></image>
			<view class="safe_text">We will ensure the security of your card informa -tion</view>
		</view>
		<view class="text">Your card may be charged to ensure its validity. The amount will be automatically refunded.Adding a card
This means that you have read and agreed to our<text>agreement and terms</text></view>

		<view class="save" :class="{ savecolo: cardnum && mm && cvv }" @click="cancleOrder">{{button}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				systemHeight: null,
				title: '',
				button: '',
				cardnum: '',
				mm: '',
				cvv: ''

			}
		},
		created() {
			this.systemHeight = uni.getSystemInfoSync().statusBarHeight
		},
		onLoad(e) {
			if (e.type == '1') {
				this.title = 'Add Card'
				this.button = 'Save'
			} else {
				this.title = 'Unbind the card'
				this.button = 'unbind'
			}
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			cancleOrder() {
				uni.navigateTo({
					url: "/pages/pay/cancelOrder"
				})
			}
		}
	}
</script>

<style>
	.box {
		display: flex;
		flex-direction: column;
		align-items: center;
		position: fixed;
		width: 100%;
		height: 100vh;
	}

	.head {
		width: 92%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 57rpx;
	}

	.back {
		width: 20rpx;
		height: 36rpx;
	}

	.title {
		font-family: Mont;
		font-weight: bold;
		font-size: 32rpx;
	}

	.right {
		width: 20rpx;
	}

	.small_title {
		width: 92%;
		font-family: Mont;
		font-weight: 600;
		font-size: 28rpx;
		margin-bottom: 27rpx;
	}

	.card {
		position: relative;
		width: 92%;
		height: 92rpx;
		background: #F4F4F4;
		border-radius: 30rpx;
		margin-bottom: 57rpx;
	}

	.card_img {
		position: absolute;
		left: 20rpx;
		top: 50%;
		transform: translate(0, -50%);
		width: 58rpx;
		height: 43rpx;
	}

	.input_card {
		margin-left: 94rpx;
		box-sizing: border-box;
		max-width: 300rpx;
		overflow: auto;
		height: 100%;
	}

	.scan {
		position: absolute;
		right: 36rpx;
		top: 50%;
		transform: translate(0, -50%);
		width: 38rpx;
		height: 35rpx;
	}

	.yy_cvv {
		width: 92%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 44rpx;
	}

	.input {
		box-sizing: border-box;
		padding-left: 34rpx;
		width: 330rpx;
		height: 92rpx;
		background: #F4F4F4;
		border-radius: 30rpx;
	}

	.safe {
		width: 92%;
		display: flex;
		margin-bottom: 36rpx;
	}

	.safe_img {
		width: 31rpx;
		height: 32rpx;
		margin-right: 10rpx;
	}

	.safe_text {
		width: 628rpx;
		font-family: Mont;
		font-weight: 500;
		font-size: 26rpx;
		line-height: 36rpx;
		white-space: pre-wrap;
		word-wrap: break-word;
	}

	.text {
		width: 92%;
		height: 129rpx;
		font-family: Mont;
		font-weight: 400;
		font-size: 20rpx;
		color: #646464;
		line-height: 36rpx;white-space: pre-wrap;
	}

	.text text {
		color: #34BA78;
		margin: 0rpx 10rpx;
	}

	.save {
		position: absolute;
		bottom: 190rpx;
		left: 50%;
		transform: translate(-50%, 0);
		width: 690rpx;
		height: 92rpx;
		background: #DFDFDF;
		border-radius: 46rpx;
		font-family: Mont;
		font-weight: bold;
		font-size: 30rpx;
		color: #888888;
		line-height: 92rpx;
		text-align: center;
	}

	.savecolo {
		background: #34BA78;
		color: #FFFFFF;
	}
</style>